package falstad;

public class manualDriver implements RobotDriver {

	private Robot robot;
	
	public manualDriver(Robot r)
	{
		this.robot = r;
	}
	
	@Override
	public void setRobot(Robot r) throws UnsuitableRobotException {
		robot = r;
		float robotBattLevel = robot.getCurrentBatteryLevel();
		float robotRotationCost = robot.getEnergyForFullRotation();
		float robotMoveCost = robot.getEnergyForStepForward();
		if ((robotBattLevel == 2500) && (robotRotationCost == 4) && (robotMoveCost == 5)) {
			try {
				robot.distanceToObstacleAhead();
				robot.distanceToObstacleBehind();
				robot.distanceToObstacleOnLeft();
				robot.distanceToObstacleOnRight();
				robot.canSeeGoalAhead();
				robot.canSeeGoalBehind();
				robot.canSeeGoalOnLeft();
				robot.canSeeGoalOnRight();
			}
			catch (UnsupportedMethodException e) {
				throw new UnsuitableRobotException();
			}
		}
	}

	@Override
	public boolean drive2Exit() throws Exception {
//		while (!robot.hasStopped() || !robot.isAtGoal()) {
//		}
//		if (robot.hasStopped()) {
//			throw new Exception();
//		}
//		else if (robot.isAtGoal()) {
//			return true;
//		}
		// returns false otherwise
		return false;
	}

	@Override
	public float getEnergyConsumption() {
		return (2500 - robot.getCurrentBatteryLevel());
	}

	@Override
	public int getPathLength() {
		return robot.getDistTraveled();
	}
}
